KISSY.use("node",function(S,Node){ 
$(".badtool").on("click",function(){
	var toolname = $(this).attr("data-tool");
	var iscfg = $(this).hasClass("tips");
	showDialog("不能使用工具","<div class=\"control-group centered \">亲，您还未开通本工具，请开通后使用。<button class=\"button assigntool\" type=\"button\" >立即开通</button><p class=\"auxiliary-text\">一个月用户可开通2款，季度用户可开通3款，半年用户可开通5款，一年用户可开通7款，一年以上用户不受限制。</p></div>","form-horizontal");
	$(".cancel").remove();
	$(".assigntool").on("click",function(){
		if(iscfg){
		assign(toolname,false,"/?c=chajian&m=shopadmin");	
		}else{
		assign(toolname,false,"/?a=gamecfg&m=shopadmin");
		}
	});
	});
$(".tool").on("click",function(){
	$(".tnm").remove();
	var tool = $(this).attr("data-tool");
	var str = '<input type="hidden" class="tnm" name="toolname" value="'+tool+'" />';
	$(str).prependTo("form");
	$(".x-icon-success").remove();
	var str = '<span class="x-icon x-icon-small x-icon-success" style="position:absolute"><i class="icon icon-white icon-ok"></i></span>';
	$(str).prependTo(this);
	
});
$(".save").on("click",function(){
	if($(".tnm").val()){
		$("form").fire("submit");
		return true;
	}else{
		showDialog("请选择活动类型","亲，你还么有选择活动类型呢！请选择后继续","form-horizontal");
		return false;
	}
});
$(".js-tool").on("mouseenter mouseleave",function(){
	var tid = $(this).attr("data-tid");
	var status = $(this).attr("data-status");
	if(!status){
	$(".timg"+tid).toggleClass("hide");
	}
});
$(".js-tool").on("click",function(){
	var toolname = $(this).attr("data-tid");
	var status = $(this).attr("data-status");
	if(!status){
		assign(toolname,false,"/?&c=chajian&m=shopadmin");
	}else{
		jump(toolname);
	}
});
function jump(toolname){
	switch(toolname){
		case "choujiang" :location.href=("/?a=gamecfg&m=shopadmin");break;
		case "jifen" :location.href=("/?c=jifen&m=shopadmin");break;
		case "cartlott" :location.href=("/?a=gamecfg&m=shopadmin");break;
		case "oidlott" :location.href=("/?a=gamecfg&m=shopadmin");break;
		case "shoucang" :location.href=("/?a=gamecfg&m=shopadmin");break;
		case "zidigyi" :location.href=("/?a=bandcfg&m=shopadmin&c=frontcfg");break;
	}
}
function assign(toolname,lowversion,url){
		KISSY.io({
			url: "/?a=assigntool&m=shopadmin",
			data: {"toolname":toolname,"lowversion":lowversion},
			success: function(data, textStatus) {
			closeDialog();
				if(data.status==false){
					showDialog("开通失败","<div class=\"control-group centered \">"+data.msg+"<a href=\"http://fuwu.taobao.com/ser/detail.htm?service_code=ts-30901\" class=\"button\" target=\"_blank\">立即订购</a></div>","form-horizontal");
					$(".lowversion").on("click",function(){
						assign(toolname,true,url);
					});
				}else{
					showDialog("开通成功！","<div class=\"control-group centered \">"+data.msg+"</div>","form-horizontal");
					$(".cancel").on("click",function(){
						location.href=(url);
					});
				}
			},
			error: function(){
				alert('error');
			},
			dataType:"jsonp"
		});
}
});
// SNS.ui("sharebtn",{"type":"webpage","title":"webpage","key":"http://www.taobao.com/go/act/sns/opendocs_sdk.php","client_id":"68","element":"#sns-widget-sharebtn"})